home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / games / strategy / empire-2.2w.lzh / Doc / Update < prev    next >
Text File  |  1990-08-25  |  9KB  |  232 lines

  1.                 Amiga Empire by Chris Gray - Updating
  2.  
  3. This section is quite detailed. The details are provided so that those who
  4. want to run their country optimally can see what they need to see. Others
  5. (especially beginners) should just ignore this section until they have
  6. played for a while, at which point they should scan it to get a feel for
  7. how things happen.
  8.  
  9. The sector update algorithm is central to Empire. It is based on steady
  10. change over Empire Time Units. It can be summarized as follows (values are
  11. either for the sector being updated or for the owner country of the sector;
  12. all calculations are integral):
  13.  
  14. NOTE: A deity can change most of the magic numbers.
  15.  
  16.     proc makeProduction():
  17.         q := min(work * efficiency / 100, ore);
  18.         if <sector not contracted> then
  19.             if money > 0 then
  20.                 q := min(q, 127 - production);
  21.                 production := production + q;
  22.             fi;
  23.         else
  24.             q2 := q * priceInNickels / 20;
  25.             money := money + q2;
  26.         fi;
  27.         ore := ore - q;
  28.     corp;
  29.  
  30.     /* in an urban center, people are lazy, so every 10 counts as 1 here */
  31.     workForce := civilians + military / 5;
  32.     if lastUpdate = 0 or lastUpdate > CurrentTime then
  33.         lastUpdate := CurrentTime;
  34.     fi;
  35.     deltaTime := CurrentTime - lastUpdate;
  36.     if deltaTime > 256 then
  37.         deltaTime := 256;
  38.     fi;
  39.     work := deltaTime * workForce;
  40.     if work >= 100 and (<I own this sector> or work > 48 * 2 * 100) then
  41.         if weather <= -9 then
  42.             /* hurricane */
  43.             damageSector(random(21) + 70);
  44.         elif weather <= -8 then
  45.             /* no construction happens */
  46.         else
  47.             q := 0;
  48.             if weather <= -7 then
  49.                 if money > 0 then
  50.                     q := min(work / 200, 100 - efficiency);
  51.                 fi;
  52.                 mobility := min(127, mobility + deltaTime / 2);
  53.             else
  54.                 if money > 0 then
  55.                     q := min(work / 100, 100 - efficiency);
  56.                 fi;
  57.                 mobility := min(127, mobility + deltaTime);
  58.             fi;
  59.             efficiency := efficiency + q;
  60.             money := money - q;
  61.         fi;
  62.         /* civilian growth */
  63.         q := deltaTime * civilians;
  64.         if designation = <urban area> then
  65.             q := min(127, civilians + min(q / 100, ore)) - civilians;
  66.             civilians := civilians + q;
  67.             ore := ore - q;
  68.         elif designation = <bridge span> then
  69.             civilians := civilians - q / 400;
  70.         elif civilians > 31 and civilians < 97 then
  71.             civilians := min(127, civilians + q / 200);
  72.         else
  73.             civilians := min(127, civilians + q / 400);
  74.         fi;
  75.         /* mobility increase */
  76.         mobility := min(127, mobility + deltaTime);
  77.         lastUpdate := lastUpdate + deltaTime;   /* NOTE THIS!!! */
  78.         /* military supplies */
  79.         q := military / 32 * deltaTime / 8;
  80.         money := money - q;
  81.         if <this is owner's active capital> then
  82.             BTUs :=
  83.                 min(96, BTUs + deltaTime * civilians * efficiency / 5000);
  84.             researchLevel :=
  85.                 researchLevel - researchLevel * deltaTime / 4800;
  86.             techLevel := techLevel - techLevel * deltaTime / 4800;
  87.         fi;
  88.         case plague_stage:
  89.         incase 3:
  90.             /* terminal plague stage */
  91.             <kill some people off>;
  92.             <send telegram, make news>;
  93.             if plague_time <= deltaTime then
  94.                 plague_stage := 0;
  95.             else
  96.                 plague_time := plague_time - deltaTime;
  97.             fi;
  98.         incase 2:
  99.             /* infectious stage */
  100.             if plague_time <= deltaTime then
  101.                 plague_stage := 3;
  102.                 plague_time := random(33) + 32;
  103.             else
  104.                 plague_time := plague_time - deltaTime;
  105.             fi;
  106.         incase 1:
  107.             /* gestatory stage */
  108.             if plague_time <= deltaTime then
  109.                 plague_stage := 2;
  110.                 plague_time := random(33) + 32;
  111.                 <send telegram, create news>;
  112.             else
  113.                 plague_time := plague_time - deltaTime;
  114.             fi;
  115.         incase 0:
  116.             /* not infected - see if it should become so */
  117.             plagueFactor :=
  118.                     ((civilians + military) / 254) *
  119.                     ((techLevel + ore + 100) /
  120.                      (researchLevel + efficiency + mobility + 100));
  121.             if random(100) < plagueFactor then
  122.                 plague_stage := 1;
  123.                 plague_time := random(33) + 32;
  124.             fi;
  125.         esac;
  126.         /* note that 'move', and deliveries will pass the plague when it is
  127.            in the infectious stage */
  128.         <do any deliveries out of this sector - special handling is done
  129.          when delivering civilians or military into a sector that hasn't
  130.          been updated for a long time>
  131.         if efficiency >= 60 then                /* NOTE THIS!!! */
  132.             case designation
  133.             incase <bank>:
  134.                 /* interest */
  135.                 money := money + deltaTime * goldBars / 2;
  136.             incase <capital>:
  137.             incase <radar station>:
  138.             incase <weather station>:
  139.                 /* utilities */
  140.                 money := money - deltaTime;
  141.             incase <technology center>:
  142.             incase <research institute>:
  143.                 /* utilities */
  144.                 money := money - deltaTime;
  145.                 if money > 0 then
  146.                     q := production / 25;
  147.                     production := production - q * 25;
  148.                     if designation = <technology center> then
  149.                         techLevel := techLevel + q;
  150.                     else
  151.                         researchLevel := researchLevel + q;
  152.                     fi;
  153.                 fi;
  154.                 makeProduction();
  155.             incase <defense plant>:
  156.                 if money > 0 then
  157.                     q := min(production / 10, 127 - guns);
  158.                     production := production - q * 10;
  159.                     guns := guns + q;
  160.                 fi;
  161.                 makeProduction();
  162.             incase <shell industry>:
  163.                 if money > 0 then
  164.                     q := min(production / 2, 127 - shells);
  165.                     production := production - q * 2;
  166.                     shells := shells + q;
  167.                 fi;
  168.                 makeProduction();
  169.             incase <airfield>:
  170.                 if money > 0 then
  171.                     q := min(production / 25, 127 - planes);
  172.                     production := production - q * 25;
  173.                     planes := planes + q;
  174.                 fi;
  175.                 makeProduction();
  176.             incase <harbor>:
  177.             incase <bridge head>:
  178.                 makeProduction();
  179.             incase <gold mine>:
  180.                 q := min(production / 5, 127 - goldBars);
  181.                 production := production - q * 5;
  182.                 goldBars := goldBars + q;
  183.                 q := min(goldSample * work * effic / 1000000, goldSample);
  184.                 if <sector not contracted> then
  185.                     if money > 0 then
  186.                         q := min(q, (127 - production) / 2);
  187.                         production := production + q * 2;
  188.                     fi;
  189.                 else
  190.                     q2 := q * 2 * priceInNickels / 20;
  191.                     money := money + q2;
  192.                 fi;
  193.                 goldSample := goldSample - q;
  194.             incase <mine>:
  195.                 q := mineralSample * efficiency * work / 10000;
  196.                 if <sector not contracted> then
  197.                     if money > 0 then
  198.                         ore := min(127, ore + q);
  199.                     fi;
  200.                 else
  201.                     q2 := q * priceInNickels / 20;
  202.                     money := money + q2;
  203.                 fi;
  204.             esac;
  205.         fi;
  206.     fi;
  207.  
  208. Ship updates are much simpler:
  209.  
  210.     if lastUpdate = 0 or lastUpdate > CurrentTime then
  211.         lastUpdate := CurrentTime;
  212.     fi;
  213.     deltaTime := CurrentTime - lastUpdate;
  214.     if deltaTime >= 3 then
  215.         lastUpdate := lastUpdate + deltaTime;
  216.         if weather <= -9 and shipType ~= 's' then
  217.             damageShip((random(21) + 10) * shipDamageFactor(shipType));
  218.         elif weather <= -8 and shipType ~= 's' then
  219.             /* bad weather halts construction */
  220.         else
  221.             if weather <= -7 and shipType ~= 's' then
  222.                 /* bad weather delays construction */
  223.                 deltaTime := deltaTime / 2;
  224.             fi;
  225.             mobility := min(127, mobility + deltaTime);
  226.             efficiency := min(100, efficiency + deltaTime);
  227.             techLevel :=
  228.                 techLevel - techLevel * dt * shipTechDecreaser / 480000;
  229.         fi;
  230.     fi;
  231.  
  232.